#ifndef MEMORYBLOCK_H
#define MEMORYBLOCK_H
#include "StompedReality/Base.h"
#include "StompedReality/Core.h"
namespace StompedReality
{
class IGame;
namespace Core
{
template <class T>
class ObjectPoolManager;

/*!
 * \author	Stefan Kazalski
 *
 * \brief	Memroy block allocation.
 */
template <class T>
class DLL_EXPORT MemoryBlock
{
  friend class ObjectPoolManager<T>;

 protected:

  // Cosntructor & Destructor
  MemoryBlock( ) {
  }

  virtual ~MemoryBlock( ) {
  }

 public:

  //! \brief TypeId getter.
  virtual StompedReality::TYPE_ID GetTypeID( ) = 0;

  //! \brief	Creates new object.
  //!			Creates a new object and returns its id.
  //!			Calls objects onCreation() method.
  //! \param	game	The game.
  //! \return	The object id.
  virtual ID Create ( StompedReality::IGame* game ) = 0;

  //! \brief	Tests if object with id exists.
  virtual bool Contains ( ID id ) = 0;

  //! \brief	Returns the object.
  //! \return	Object if exists otherwrise NULL.
  virtual T* Get ( ID id ) = 0;

  //! \brief Removes an object from the block.
  virtual void Remove ( ID id ) = 0;

  //! \brief	Checks if an object is stored at the index.
  //! \param	idx	The index.
  //! \return	Does obejct exists at this position.
  virtual bool IsObjectAt( int idx ) = 0;

  //! \brief Return object at index.
  //! \param	idx	The index.
  //! \return	Return the object or NULL if it does not exits.
  virtual T* GetObjectAt( int idx ) = 0;

  //! \brief	GetCapacity
  virtual int GetCapacity( ) = 0;
};

}
}
#endif // MEMORYBLOCK_H
